
local boxPlafon = {
    {-0.4375, -0.375, -0.4375, 0.4375, -0.1875, 0.4375}, -- plafon
    {-0.125, -0.5, -0.125, 0.125, -0.3125, 0.125}, -- enganche
}


minetest.register_node("morelanterns:plafon", {
	description = "Plafon",
	-- drawtype = "mesh",
	-- mesh = "torch_floor.obj",
	--inventory_image = "default_torch_on_floor.png",
	-- wield_image = "default_torch_on_floor.png",
	--tiles = {{
	--	    name = "default_torch_on_floor_animated.png",
	--	    animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
	--}},
	
	drawtype = "nodebox",
	node_box = {
		type = "fixed",
		fixed = boxPlafon
	},

	--node_box = {
	--	type = "fixed",
	--	wall_top = formas["morelanterns_candil_techo"],
	--	wall_bottom = formas["morelanterns_candil_suelo"],
	--		wall_side = formas["morelanterns_candil"]
	--},

	inventory_image = "morelanterns_plafon00.png",
	wield_image = "morelanterns_plafon00.png",
	tiles = { "morelanterns_plafon00.png" },
	use_texture_alpha = "clip",
	paramtype = "light",
	paramtype2 = "wallmounted",
	sunlight_propagates = true,
	walkable = false,
	liquids_pointable = false,
	light_source = LIGHT_LEVELS.high,
	groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, lantern=1},
	drop = "morelanterns:plafon",
	nodebox = {
		type = "wallmounted",
		wall_bottom = boxPlafon,
		wall_side= boxPlafon,
		wall_top = boxPlafon
	},
	sounds = default.node_sound_wood_defaults(), 
	
	on_place = function(itemstack, placer, pointed_thing)
		local under = pointed_thing.under
		local node = minetest.get_node(under)
		local def = minetest.registered_nodes[node.name]
		if def and def.on_rightclick and
			not (placer and placer:is_player() and
			placer:get_player_control().sneak) then
			-- minetest.chat_send_all("DENTRO IF")
			
			return def.on_rightclick(under, node, placer, itemstack,
				pointed_thing) or itemstack
		end
		-- minetest.chat_send_all("FUERA IF")
		local above = pointed_thing.above
		local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
		local fakestack = itemstack
		if wdir == 0 then
			fakestack:set_name("morelanterns:plafon")
		elseif wdir == 1 then
			fakestack:set_name("morelanterns:plafon")
		else
			fakestack:set_name("morelanterns:plafon")
		end
		
		itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
		itemstack:set_name("morelanterns:plafon")

		return itemstack
	end,
	
	floodable = true,
	on_flood = on_flood,
	on_rotate = false
})

minetest.register_craft({
    output = "morelanterns:plafon",
    recipe = {{"default:gold_ingot"},
              {"torch"},
              {"default:glass"}
            }
})